/* 
#include <bits/stdc++.h>
#define INF 999999999

using namespace std;
class Dijkstra_Record{
	public:
		bool visited;
		int length;
		int num;
		int weight;
		Dijkstra_Record(){	visited = num = weight = 0;	length = INF;} 
};
class MGraph{
	public:
		int **matrix;
		int vertexNum;
};
int Dijkstra(int s, int v, MGraph *mg, int *weight, Dijkstra_Record *dr)
{
	int n = mg->vertexNum, i, j;
	dr[s].num = 1;
	dr[s].length = 0;
	dr[s].weight = weight[s];
	for(i = 0; i < n; i++){
		int min = INF, cur = -1;
		for(j = 0; j < n; j++)
			if(!dr[j].visited && dr[j].length < min)
				min = dr[cur = j].length;
		if(cur == -1)
			return -1;
		dr[cur].visited = true;
		for(j = 0; j < n; j++){
			int newLen = dr[cur].length + mg->matrix[cur][j]; 			
			if(!dr[j].visited && mg->matrix[cur][j] != INF 
					&& mg->matrix[cur][j] != 0){
				if(newLen < dr[j].length){
					dr[j].length = newLen;
					dr[j].num = dr[cur].num;
					dr[j].weight = dr[cur].weight + weight[j];
				}else if(newLen == dr[j].length){
					dr[j].num = dr[j].num + dr[cur].num;
					if(dr[j].weight < dr[cur].weight + weight[j])
						dr[j].weight = dr[cur].weight + weight[j];
				}
			}
		}
	}
}
int main()
{
	int vertexNum, edgeNum, s, v, i, j;
	cin >> vertexNum >> edgeNum >> s >> v;
	int *weight = new int[vertexNum];
	for(i = 0; i < vertexNum; i++)
		cin >> weight[i];
	MGraph *mg = new MGraph();
	mg->vertexNum = vertexNum;
	mg->matrix = new int*[vertexNum];
	for(i = 0; i < vertexNum; i++){
		mg->matrix[i] = new int[vertexNum];
		fill(mg->matrix[i], mg->matrix[i] + vertexNum, INF);
		mg->matrix[i][i] = 0; 
	}
	int start, end, edgeWeight;
	for(i = 0; i < edgeNum; i++){
		cin >> start >> end >> edgeWeight;
		mg->matrix[start][end] = mg->matrix[end][start] = edgeWeight;
	}
	Dijkstra_Record *dr = new Dijkstra_Record[vertexNum];
	Dijkstra(s, v, mg, weight, dr);
	cout << dr[v].num << " " << dr[v].weight;
	return 0;
} 
*/
#include <bits/stdc++.h>
#define INF 999999999
using namespace std;
class Dijkstra_Record{
	public:
		bool visited;
		int length;
		int num;
		int weight;
		Dijkstra_Record(){	visited = num = weight = 0;	length = INF;} 
};
class MGraph{
	public:
		int **matrix;
		int vertexNum;
		int Dijkstra(int s, int v, MGraph *mg, int *weight, Dijkstra_Record *dr)
		{
			int n = mg->vertexNum, i, j;
			dr[s].num = 1;
			dr[s].length = 0;
			dr[s].weight = weight[s];
			for(i = 0; i < n; i++){
				int min = INF, cur = -1;
				for(j = 0; j < n; j++)
					if(!dr[j].visited && dr[j].length < min)
						min = dr[cur = j].length;
				if(cur == -1)
					return -1;
				dr[cur].visited = true;
				for(j = 0; j < n; j++){
					int newLen = dr[cur].length + mg->matrix[cur][j]; 			
					if(!dr[j].visited && mg->matrix[cur][j] != INF ) 
						if(newLen < dr[j].length){
							dr[j].length = newLen;
							dr[j].num = dr[cur].num;
							dr[j].weight = dr[cur].weight + weight[j];
						}else if(newLen == dr[j].length){
							dr[j].num = dr[j].num + dr[cur].num;
							if(dr[j].weight < dr[cur].weight + weight[j])
								dr[j].weight = dr[cur].weight + weight[j];
						}
				}
			}
		}
};

int main()
{
	int vertexNum, edgeNum, s, v, i, j;
	cin >> vertexNum >> edgeNum >> s >> v;
	int *weight = new int[vertexNum];
	for(i = 0; i < vertexNum; i++)
		cin >> weight[i];
	MGraph *mg = new MGraph();
	mg->vertexNum = vertexNum;
	mg->matrix = new int*[vertexNum];
	for(i = 0; i < vertexNum; i++){
		mg->matrix[i] = new int[vertexNum];
		fill(mg->matrix[i], mg->matrix[i] + vertexNum, INF);
	}
	int start, end, edgeWeight;
	for(i = 0; i < edgeNum; i++){
		cin >> start >> end >> edgeWeight;
		mg->matrix[start][end] = mg->matrix[end][start] = edgeWeight;
	}
	Dijkstra_Record *dr = new Dijkstra_Record[vertexNum];
	mg.Dijkstra(s, v, mg, weight, dr);
	cout << dr[v].num << " " << dr[v].weight;
	return 0;
}  
